package co.sanduche.services;

import static co.sanduche.util.HttpUtils.urlInterpolate;

import java.util.List;

import co.sanduche.models.Models.Classroom;
import co.sanduche.models.Models.Person;
import co.sanduche.models.Models.Photo;
import co.sanduche.models.Models.Post;
import co.sanduche.models.Models.Student;
import co.sanduche.models.Models.User;
import co.sanduche.util.EPCallback;
import co.sanduche.util.JListRequest;
import co.sanduche.util.JObjectRequest;
import co.sanduche.vos.LoginCredentials;

import com.android.volley.Request.Method;

public class EndPoints {

	public static class PostsEP {
		public static void post(Post body, EPCallback<Post> handler) {
			EPClient.addRequest(new JObjectRequest<Post>(Method.POST,
					urlInterpolate("/api/post/post"), body, Post.class, handler));
		}

		public static void getClassrooms(EPCallback<List<Classroom>> handler) {
			EPClient.addRequest(new JListRequest<Classroom>(Method.GET,
					urlInterpolate("/api/post/classroom"), null,
					Classroom.class, handler));
		}

		public static void uploadPhoto(Photo body, EPCallback<Photo> handler) {
			EPClient.addRequest(new JObjectRequest<Photo>(Method.POST,
					urlInterpolate("/api/post/photo"), body, Photo.class,
					handler));
		}

		public static void getStudents(Long idClassroom,
				EPCallback<List<Student>> handler) {
			EPClient.addRequest(new JListRequest<Student>(Method.GET,
					urlInterpolate("/api/post/classroom/:idClassroom/student",
							"idClassroom", idClassroom), null, Student.class,
					handler));
		}

		public static void updateDescription(Long id, Photo body,
				EPCallback<Photo> handler) {
			EPClient.addRequest(new JObjectRequest<Photo>(Method.PUT,
					urlInterpolate("/api/post/photo/:id", "id", id), body,
					Photo.class, handler));
		}
	}

	public static class UserEP {
		public static void saveAndroidId(String idAndroid,
				EPCallback<Void> handler) {
			EPClient.addRequest(new JObjectRequest<Void>(Method.POST,
					urlInterpolate("/api/device/android/:idAndroid",
							"idAndroid", idAndroid), null, Void.class, handler));
		}

		public static void login(LoginCredentials body, EPCallback<Void> handler) {
			EPClient.addRequest(new JObjectRequest<Void>(Method.POST,
					urlInterpolate("/api/login"), body, Void.class, handler));
		}

		public static void logout(EPCallback<Void> handler) {
			EPClient.addRequest(new JObjectRequest<Void>(Method.GET,
					urlInterpolate("/api/user/logout"), null, Void.class,
					handler));
		}

		public static void getMyInfo(EPCallback<User> handler) {
			EPClient.addRequest(new JObjectRequest<User>(Method.POST,
					urlInterpolate("/api/user/self"), null, User.class, handler));
		}

		public static void getPersonasConDocumento(String documento,
				EPCallback<List<Person>> handler) {
			EPClient.addRequest(new JListRequest<Person>(Method.GET,
					urlInterpolate("/api/person/:documento", "documento",
							documento), null, Person.class, handler));
		}
	}

	public static class CoordinatorEP {

	}

}
